package com.geek.bams.entity;

import javax.swing.*;
import java.io.Serializable;

/**
 * @Desc TODO
 * @Author wangpeng
 * @Date 2025/10/13
 */
public class CreditAccount extends Account{

    private double ceiling;

    public CreditAccount() {
    }

    public CreditAccount(Long id, String name, String password, String personId, String email, double balance, double ceiling) {
        super(id, name, password, personId, email, balance);
        this.ceiling = ceiling;
    }

    /**
     * 取款方法
     * @param money  取钱
     * @return
     */
    @Override
    public Account withdraw(double money) {
        if(this.getBalance()+this.ceiling>=money){
            if(this.getBalance()>=money){
                this.setBalance(this.getBalance()-money);
            }else{
                this.ceiling-=(money-this.getBalance());
                this.setBalance(0.0);
            }
        }else{
            //System.out.println("您的账户余额不足！");
            JOptionPane.showMessageDialog(null, "您的账户余额不足！");

        }
        return this;
    }

    /**
     * 获取
     * @return ceiling
     */
    public double getCeiling() {
        return ceiling;
    }

    /**
     * 设置
     * @param ceiling
     */
    public void setCeiling(double ceiling) {
        this.ceiling = ceiling;
    }

    @Override
    public String toString() {
        return "CreditAccount{" +
                "ceiling=" + ceiling +
                "} " + super.toString();
    }
}
